#include <glib.h>

void _list_interger_print_func(gpointer data, gpointer user_data)
{
    g_print("data is: %d, user_data is: %s \n", GPOINTER_TO_INT(data), (gchar *)user_data);
}

gint main(gint argc, gchar **argv)
{
    GList *list = NULL;
    GList *l = NULL;

    list = g_list_append(list, GINT_TO_POINTER(1));
    list = g_list_append(list, GINT_TO_POINTER(5));
    list = g_list_append(list, GINT_TO_POINTER(3));
    list = g_list_append(list, GINT_TO_POINTER(5));
    list = g_list_append(list, GINT_TO_POINTER(5));
    list = g_list_append(list, GINT_TO_POINTER(7));

    g_list_foreach(list, _list_interger_print_func, (gchar *)"original list");

    list = g_list_remove(list, GINT_TO_POINTER(5));

    g_list_foreach(list, _list_interger_print_func, (gchar *)"after remove 5");

    list = g_list_remove_all(list, GINT_TO_POINTER(5));

    g_list_foreach(list, _list_interger_print_func, (gchar *)"after remove_all 5");

    l = g_list_last(list);

    list = g_list_remove_link(list, l);

    g_list_free(l);

    l = g_list_first(list);

    list = g_list_delete_link(list, l);

    g_list_foreach(list, _list_interger_print_func, (gchar *)"after remove first and last");

    g_list_free(list);

    return 0;
}